package com.tengju.user.domain.model.archive.sign;

import java.util.Objects;

/**
 * 签约来源
 */
public enum SignFromEnum {
    TO_SIGN(0, "待签约"),

    SERVICE_FEE(1, "服务费"),

    SERVICE_PROVIDER(2, "星际区域服务商");

    private SignFromEnum(Integer code, String descriptioin) {
        this.code = code;
        this.descriptioin = descriptioin;
    }

    private Integer code;

    private String descriptioin;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDescriptioin() {
        return descriptioin;
    }

    public void setDescriptioin(String descriptioin) {
        this.descriptioin = descriptioin;
    }

    public static Integer getFromCode(Integer fromType) {
        if (Objects.isNull(fromType)) {
            return SignFromEnum.SERVICE_FEE.getCode();
        }
        for (SignFromEnum fromEnum : SignFromEnum.values()) {
            if (fromType.equals(fromEnum.getCode())) {
                return fromEnum.getCode();
            }
        }
        return SignFromEnum.SERVICE_FEE.getCode();
    }

    public static SignFromEnum form(Integer fromType) {
        SignFromEnum signFromEnum = SignFromEnum.SERVICE_FEE;
        for (SignFromEnum fromEnum : SignFromEnum.values()) {
            if (fromType.equals(fromEnum.getCode())) {
                signFromEnum = fromEnum;
            }
        }
        return signFromEnum;
    }
}
